//freopen!!!!!!!!!!!!!!!
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	
	long long n,l,r,i,ans=0;
	cin>>n>>l>>r;
	if(r-l>=n)
	{
		cout<<n-1;
		return 0;
	}
	long long idk=n*(l%n+1)-1;
	if(l<=idk&&idk<=r)cout<<n-1;
	else cout<<r%n;
	
	
	
	
	
	return 0;
}
